package com.hsd.znsh.repository;

import com.hsd.znsh.entity.Sensor;
import com.hsd.znsh.entity.SensorData;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-23 11:54:50
 */
public interface SensorDataRepository extends JpaRepository<SensorData,Integer> {

    void deleteBySensorSn(String sensorSn);

    SensorData findBySensorSnAndTimeAndPropertyId(String sensorSn,Date time,Integer propertyId);

    List<SensorData> findBySensorSnAndTimeGreaterThanEqualAndPropertyIdOrderByTimeAsc(
            String sensorSn, Date time,Integer propertyId);

    List<SensorData> findBySensorSnAndTimeGreaterThanEqualAndPropertyIdOrderByTimeAsc(
            String sensorSn, Date time,Integer propertyId, Pageable pageable);

    List<SensorData> findBySensorSnAndTimeBetweenAndPropertyIdOrderByTimeAsc(
            String sensorSn, Date start,Date end,Integer propertyId);

    List<SensorData> findBySensorSnAndTimeInAndPropertyIdOrderByTimeAsc(
            String sensorSn, List<Date> dates,Integer propertyId);

}
